<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>利用位移实现水平垂直居中</title>
        <style>
            *{
                margin: 0;
                padding: 0;
            }
            #big{
                border: 1px solid pink;
                width: 500px;
                height: 500px;
                position: relative;
            }
            #small{
                /*width: 50px;
                height: 50px;*/
                background: #bbbbbe;
                position: absolute;
                top: 50%;
                left: 50%;
                transform: translate(-50%,-50%);
            }
        </style>
    </head>
    <body>
        <div id="big">
            <div id="small">sffafa</div>
        </div>
    </body>
</html>